<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>fetch ajax请求</button>

    <script>
      let btn = document.querySelector('button');
      btn.onclick = function () {
            //get请求
            fetch(`http://localhost:3015/server/3?name=tom&age=12`,{

                method:'POST',
                headers:{
                    'Content-Type':'application/x-www-form-urlencoded',
                },

                body : JSON.stringify({a:1,b:2})

            }).then(response=>{

                return response.json()
            }).then(data=>{
                console.log(data);
            })

            
      };
    </script>
  </body>
</html>
